package com.splic.quartz.task;

import com.splic.product.domain.HotSearchKeyword;
import com.splic.product.service.*;
import com.splic.product.service.impl.thirdRequest.TodayInHistoryRequestServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.splic.common.utils.StringUtils;

import java.util.Date;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Component("ryTask")
@Slf4j
public class RyTask
{

    @Autowired
    private UserMotionDataService userMotionDataService;
    @Autowired
    private HotsearchKeywordService hotsearchKeywordService;
    @Autowired
    private ExchangeRateService exchangeRateService;
    @Autowired
    private WeatherService weatherService;
    @Autowired
    private TodayInHistoryService todayInHistoryService;
    @Autowired
    private HolidayVacationsService holidayVacationsService;
    @Autowired
    private ClearUserSubStatusService clearUserSubStatusService;
    @Autowired
    private VoiceTransferService voiceTransferService;

    @Value("${ruoyi.task}")
    private Boolean task;

    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }

    public void motionRankingStats(){
        log.info("运动量排名统计开始:{}",new Date());
        userMotionDataService.motionRankingStats();
        log.info("运动量排名统计结束:{}",new Date());
    }

    public void hotSearchStats(){
        log.info("热搜排名统计开始:{}",new Date());
        hotsearchKeywordService.statisticsSearch();
        log.info("热搜排名统计结束:{}",new Date());
    }


    public void exchangeRateQuery(){
        log.info("汇率数据查询开始:{}",new Date());
        exchangeRateService.requestThirdData();
        log.info("汇率数据查询结束:{}",new Date());
    }

    public void weatherQuery(){
        log.info("天气数据查询开始:{}",new Date());
        weatherService.requestThirdData();
        log.info("天气数据查询结束:{}",new Date());
    }

    public void todayInHistoryQuery(){
        log.info("历史上的今天数据查询开始:{}",new Date());
        todayInHistoryService.requestThirdData();
        log.info("历史上的今天数据查询结束:{}",new Date());
    }

    public void holidayVacationsQuery(){
        log.info("节假日数据查询开始:{}",new Date());
        holidayVacationsService.requestThirdData();
        log.info("节假日数据查询结束:{}",new Date());
    }
    public void clearUserSubStatus(){
        log.info("用户订阅状态清空开始:{}",new Date());
        clearUserSubStatusService.clearUserSubStatus();
        log.info("用户订阅状态清空结束:{}",new Date());
    }

    public void transferCallback(){
        if (task) {
            log.info("回调重试开始:{}",new Date());
            voiceTransferService.transferCallbackTask();
            log.info("回调重试结束:{}",new Date());
        }
    }

}
